package com.woniu.product.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniu.product.client.FootPrintQueryClient;
import com.woniu.product.client.result.FootprintResultInfo;
import com.woniu.product.service.LxlgFootprintService;
import com.woniu.product.service.dto.FootprintDto;
import com.woniu.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
public class FootPrintQueryApiImpl implements FootPrintQueryClient {

    @Resource
    private LxlgFootprintService lxlgFootprintService;

    /**
     * 查看足迹
     * @param userId
     * @return
     */
    @Override
    public Result getUserFootPrint(Integer userId) {
        List<FootprintDto> footPrint = lxlgFootprintService.getFootPrint(userId);
        List<FootprintResultInfo> footprintResultInfos = BeanUtil.copyToList(footPrint, FootprintResultInfo.class);
        return Result.getInstance(List.class).setData(footprintResultInfos);
    }
}
